package com.dbzf.dao.impl;

import com.dbzf.dao.AdminDao;
import com.dbzf.dao.BaseDao;
import com.dbzf.entity.Admin;

import java.sql.ResultSet;
import java.sql.SQLException;

public class AdminDaoImpl implements AdminDao {
    private ResultSet resultSet;

    @Override
    public Admin login(String name) {
        Admin admin = null;
        String sql = "select * from admin where name = ?";
        Object[] pram = {name};
        resultSet = BaseDao.getResultSet(sql,pram);
        try {
            if (resultSet.next()){
                admin = new Admin(resultSet.getString("name"),resultSet.getString("password"));
                System.out.println(admin);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeAll(BaseDao.connection,BaseDao.stmt,resultSet);
        }
        return admin;
    }
}
